/*----------------------初始化总价与商品总件数-------------------------*/
/*var aShopListWrap = $('.shopListWrap');
for(var i = 0,len = aShopListWrap.length;i < len;i ++){
	var aA = aShopListWrap.eq(i).find('a');
	var sumNum = 0;
	var sumPrice = 0;
	for(var j = 0,aLen = aA.length;j < aLen;j ++){
		sumNum =sumNum - (-parseInt(aA.eq(j).find('.goodsNum').html()));
		sumPrice = sumPrice - (-parseFloat(aA.eq(j).find('.singlePrice').html()).toFixed(2));
	}
	aShopListWrap.eq(i).find('.sumNumber').html(sumNum);
	aShopListWrap.eq(i).find('.sumPrice').html(sumPrice);
}*/
mui.init();
(function($) {
	//页面a标签的点击跳转事件
mui('.mui-slider-group').on('tap', 'a', function (e) {
if (!this.classList.contains('mui-disabled')) {
mui.openWindow({
url: this.getAttribute('href'),
id: 'info'
});
}
else {
mui.preventDefault(e);
mui.stopPropagation(e);
}
});

//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
	bounce: false,
	indicators: true, //是否显示滚动条
	deceleration:deceleration
});
$.ready(function() {
	//循环初始化所有下拉刷新，上拉加载。
	$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
		$(pullRefreshEl).pullToRefresh({
			up: {
				callback: function() {
					var self = this;
					var refund = null;
					var index = this.element.querySelector('.mui-table-view').getAttribute('index');
					refund = this.element.querySelector('.mui-table-view').getAttribute('refund');
					var numObj = this.element.querySelector('#pageNum');
					var ul = self.element.querySelector('.mui-table-view');
					var loadMore = this.element.querySelector('.mui-pull-loading');
					var my = document.createElement('my');
					var dataStatus = false;
					$.ajax({
						url:'/maidian/trade/indexTradeListWeifukuan.htm',
						type:'get',
						dataType:'html',
						data:{
							'status':index,
							'pageNo':numObj.value,
							'refund':refund
						},
						success:function(data){
							if(!(data.replace(/(^\s*)|(\s*$)/g,"") == '')){
								numObj.value = numObj.value -(-1);
								my.innerHTML = data;
								ul.appendChild(my);
							}else{
								dataStatus = true;
								loadMore.innerHTML = '没有更多数据了';
							}
						}
					});
					self.endPullUpToRefresh(dataStatus);
				}
			}
		});
	});
});
})(mui);
mui('.mui-scroll').on('tap', 'a', function (e) {
	var href = $(this).attr('href');
	var status = $(this).attr('status');
	var obj = $(href);
	$.ajax({
		url:'/maidian/trade/indexTradeListWeifukuan.htm',
		type:'get',
		dataType:'html',
		data:{
			'status':status
		},
		success:function(data){
			obj.find('.mui-table-view').html(data);
			var aLi = obj.find('ul').find('li').length;
			if(aLi >= $('#pageSize').val()){
				$('.mui-pull-bottom-tips').show();
			}else{
				$('.mui-pull-bottom-tips').hide();
			}
			if(status==1){
				//发货
				$('.status').on('click',function(){
					$('.addTip').show();
					$('.promptBg').show();
				})
				$('.btnCancel').on('click',function(){
					$('.addTip').hide();
					$('.promptBg').hide();
				})
				$('.btnSubmit').on('click',function(){
					var val = $(this).parent().parent().find('.content').val();
					$.ajax({
						url:'/maidian/trade/indexTradeListWeifukuan.htm',
						type:'get',
						dataType:'html',
						data:{
							'status':val
						},
						success:function(data){
							
							}
						})
				})
			}
			
		}
	});
});

